use crate::{ApplicationState, IndexState};

#[derive(Clone)]
pub struct IndexManager {
    state: IndexState,
}

#[allow(clippy::new_without_default)]
impl IndexManager {
    pub fn default() -> Self {
        Self {
            state: IndexState::IndexState,
        }
    }

    pub fn show(&mut self, ctx: &egui::Context) {
         
        egui::TopBottomPanel::top("top_panel")
            .resizable(true)
            .min_height(32.0)
            .show(ctx, |ui| {
                ui.horizontal(|ui| {
                    let button_size = egui::vec2(50.0, 50.0);
                    let button_style = egui::Button::new("用户管理")
                        .fill(egui::Color32::from_rgb(100, 150, 240)) // 背景颜色
                        .stroke(egui::Stroke::new(
                            2.0,
                            egui::Color32::from_rgb(50, 100, 200),
                        ));
                    if ui.add_sized(button_size, button_style).clicked() {
                        self.state = IndexState::USER;
                    }
                    let button_style = egui::Button::new("资源管理")
                        .fill(egui::Color32::from_rgb(100, 150, 240)) // 背景颜色
                        .stroke(egui::Stroke::new(
                            2.0,
                            egui::Color32::from_rgb(50, 100, 200),
                        ));
                    if ui.add_sized(button_size, button_style).clicked() {
                        self.state = IndexState::RESOURCE;
                    }

                    let button_style = egui::Button::new("首页")
                        .fill(egui::Color32::from_rgb(100, 150, 240)) // 背景颜色
                        .stroke(egui::Stroke::new(
                            2.0,
                            egui::Color32::from_rgb(50, 100, 200),
                        ));
                    if ui.add_sized(button_size, button_style).clicked() {
                        self.state = IndexState::IndexState;
                    }
                });
            });
    }
}
